#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n, i, j, a[100086], min = 100000, max = 0, minc = 0, maxc = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        if (a[i] < min)
        {
            min = a[i];
        }
        if (a[i] > max)
        {
            max = a[i];
        }
    }
    for (j = 0; j < n; j++)
    {
        if (a[j] == max)
        {
            maxc++;
        }
        if (a[j] == min)
        {
            minc++;
        }
    }
    printf("%d %d\n%d %d", min, minc, max, maxc);
    return 0;
}